import {
  bugStatusEscape,
  vulnerabilityDisposalPriorityEscape,
  vulnerabilityLevelEscape
} from "../../vulnerability/logic/vulnerabilityLogic";

export const leakTableCol = (_this)=>{
  return [
    {
      title: '漏洞名称',
      key: 'name',
      tooltip: true,
    },
    {
      title: '关联产品',
      key: 'productName',
      render: (h, params) => {
        let str =  params.row.productName==undefined||params.row.productName==null||params.row.productName==''?'-':params.row.publicUrl;
        return h('Tooltip', {
          props:{
            maxWidth:200,
            content:str,
            transfer:true
          }
        }, [
          h('span', str.length>5?str.slice(0,5)+'...':str)
        ])
      }
    },
    {
      title: '漏洞url地址',
      key: 'publicUrl',
      render: (h, params) => {
        let str =  params.row.publicUrl==undefined||params.row.publicUrl==null||params.row.publicUrl==''?'-':params.row.publicUrl;
        return h('Tooltip', {
          props:{
            maxWidth:200,
            content:str,
            transfer:true
          }
        }, [
          h('span', str.length>5?str.slice(0,5)+'...':str)
        ])
      }
    },
    {
      title: 'IP',
      key: 'ip',
      width: 150,
    },
    {
      title: '处置优先级',
      placement: 'top-right',
      render: (h, params) => {
        let ret= vulnerabilityDisposalPriorityEscape(params.row.disposalPriority)
        return h('Tag', {
          props: {
            color: ret.color
          },
          style: {
            width: '60px',
            'text-align': 'center'
          }
        }, ret.text)
      }
    },
    {
      title: '漏洞评级',
      render: (h, params) => {
        let ret =  vulnerabilityLevelEscape(params.row.level)
        return h('Tag', {
          props: {
            color: ret.color
          },
          style: {
            width: '80px',
            'text-align': 'center'
          }
        }, ret.text)
      }
    },
    // {
    //   title: '漏洞状态',
    //   render: (h, params) => {
    //     let ret =  bugStatusEscape(params.row.status)
    //     return h('Tag', {
    //       props: {
    //         color: ret.color
    //       },
    //       style: {
    //         width: '80px',
    //         'text-align': 'center'
    //       }
    //     }, ret.text)
    //   }
    // },
    {
      title: '操作',
      slot:'action',
      opList:_this.opList,
      width: 180
    }
  ]
}
